package edu.sctu.zhengsenwen.month201506.day20150616.network;

import java.io.InputStream;
import java.net.URL;

/**
 * Created by user15 on 2015/6/16.
 */
public class HttpUrl {
    public String getHttpUrl(String path) {
        try {
            URL url = new URL(path);
            InputStream inputStream =
                    url.openStream();
            try {
                int count = 0;
                byte[] buffer = new byte
                        [1024];

                while ((count =
                        inputStream.read(buffer)) != -1) {

                    System.out.println(new
                            String(buffer, 0, count, "utf-8"));
                }
            } catch (Exception ex) {
            }
        } catch (Exception ex) {
        }
        return path;
    }

    public static void main(String[] args) {

        HttpUrl http = new HttpUrl();

        http.getHttpUrl
                ("http://www.baidu.com");


    }
}
